package work;
import java.util.Arrays;
import java.util.Scanner;
/**
 * @author AYQ
 * @Title:
 * @Description:
 * @date 2020/4/1813:51
 */
public class Management {
    //输入课程的数量
    System.out.println("请输入课程数量：");
    Scanner courseNum = new Scanner(System.in);
    Course[] courses = new Course[courseNum.nextInt()];
        for(int i = 0; i < courses.length; i++) {
        courses[i] = new Course();
        System.out.println("请输入课程名：");
        Scanner courseName = new Scanner(System.in);
        courses[i].setName(courseName.nextLine());
    }
    //用户输入学生数量，依次输入所有学生信息和该学生所选课
        System.out.println("\n");
        System.out.println("请输入学生数量：");
    Scanner studentNum = new Scanner(System.in);
    Student[] students = new Student[studentNum.nextInt()];
        for (int i = 0; i < students.length; i++) {
        students[i] = new Student();
        System.out.println("请输入第" + (i + 1) + "个学生姓名：");
        Scanner studentName = new Scanner(System.in);
        students[i].setName(studentName.nextLine());
        System.out.println("\n");
        System.out.println("请输入学生选课数量，且该数量不得大于" + courses.length);
        Scanner chooseCourse = new Scanner(System.in);
        int choose = chooseCourse.nextInt();
        if (choose <= courses.length) {
            System.out.println("\n");
            System.out.println("现在有这些选课，请选择序号：");
            for (int j = 0; j < courses.length; j++) {
                System.out.println(j + "." + courses[j].getName() + " ");
            }
            for (int k = 0; k < choose; k++) {
                System.out.println("\n");
                System.out.println("第" + (k+1) + "次，请选择序号：");
                Scanner studentSelect = new Scanner(System.in);
                int select = studentSelect.nextInt();
                students[i].getCourses().add(courses[select].getName());
                courses[select].getStudents().add(students[i].getName());
            }
        }

    }
        System.out.println("\n");
        System.out.println();
        for (int z = 0; z < students.length; z++) {
        System.out.print("第" + (z + 1) + "个同学" + students[z].getName() + "的选课为");
        System.out.print(students[z].getCourses()+"\n");
    }

}
